package com.hu.zhcc.shiro.service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hu.zhcc.shiro.dao.Tj_TMealsMapper;
import com.hu.zhcc.shiro.entity.tj.TMeals;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 膳食库 服务实现类
 * </p>
 *
 * @author tj
 * @since 2021-06-24
 */
@Service
public class Tj_TMealsServiceImpl extends ServiceImpl<Tj_TMealsMapper, TMeals> implements Tj_TMealsService {
    @Autowired
    private Tj_TMealsMapper tj_tMealsMapper;
    @Override
    public List<TMeals> queryAll() {
        return tj_tMealsMapper.queryAll();
    }

    @Override
    public int addTmeals(TMeals tMeals) {
        String s = String.valueOf(Integer.parseInt(tj_tMealsMapper.QueryCode())+1);
        tMeals.setCode("Sp000"+s);
        tMeals.setCreateTime(new Date());
        return tj_tMealsMapper.addTmeals(tMeals);
    }

    @Override
    public int updTmeals(TMeals tMeals) {
        tMeals.setUpdateTime(new Date());
        return tj_tMealsMapper.updTmeals(tMeals);
    }

    @Override
    public TMeals queryById(int id) {
        return tj_tMealsMapper.queryById(id);
    }
}
